<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <style>
        .mint-tab-container-wrap {display: -webkit-box;display: -ms-flexbox;display: flex;height: 100% !important;}
        .mint-tab-item.is-selected {border-left: 3px solid #26a2ff !important;border-bottom: 0px !important;color: #26a2ff;margin-bottom: -3px;background: white;}
        .mint-tab-item {display: block;-webkit-box-flex: 1;-ms-flex: 1;flex: 0 !important;height: 55px !important;width: 90px !important;text-decoration: none;background: #E9F3FF;}
        .mint-tab-item-label {color: inherit;font-size: 15px !important;line-height: 1;}
    </style>
    <script>
        document.getElementsByTagName('html')[0].style.fontSize = '15px'
    </script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="./css/common.css">
    <link rel="stylesheet" href="./css/icon.css">
    <link rel="stylesheet" href="./css/mint.min.css">
    <!-- 先引入 Vue -->
    <script src="js/vue.min.js"></script>
    <!-- 引入组件库 -->
    <script src="js/mint.min.js"></script>
    <!--web请求-->
    <script src="js/webservice.js"></script>
    <title>医嘱查询</title>
</head>
<body>
<div class="bgcolor matchH" id="app">
    <div class="flexH fixedScroll">
        <mt-navbar class="width100 flexVL fixedScroll" v-model="selected">
            <template v-for="(itm,idx)  in sheetList">
                <mt-tab-item :id="idx">
                    <div class="flexH">
                        <div class="width60">{{itm.desc }}</div>
                        <div v-if="itm.sheetOrdNum" class="padding3 width20 radius20 bgblue white marginL5 flexVC">{{itm.sheetOrdNum}}</div>
                    </div>
                </mt-tab-item>
            </template>
        </mt-navbar>
        <div class="flexG flexVL fixedScroll bgwhite" style="left: 100px;">
            <div class="flexHL bgwhite padding5 fixed">
                <div class="width15 height15 base64_ic_time_bottom marginR10"></div>
                <span class="font12 blue" @click="clickDateTime(stDateTime)">{{stDateTime}}</span>
                <span class="font12 padding5">至</span>
                <span class="font12 blue" @click="clickDateTime(endDateTime)">{{endDateTime}}</span>
            </div>
            <div class="flexVL marginT50 flexG">
                <div v-for="(item,indx) in orders"  class="flexVL marginT5" :key="item.bedCode">
                        <!--   某个患者信息 -->
                        <div class="font20 fontBold colorblue">{{item.bedCode+"  "+item.name}}</div>
                        <div  v-for="(item2,indx2) in item.patOrds" class="flexVL marginT5" :key="indx2">
                            <div class="flexHL" >
                                <div class="font12 width70 marginT5 radius20 center" :style="getDisposeStatColor(item2[0].orderInfo.disposeStatCode)">
                                    {{item2[0].orderInfo.disposeStatCode.split("^")[0]}}
                                </div>
                                <div v-if="item2[0].orderInfo.filteFlagExtend=='JP'"
                                     class="font12 width40 marginT5 radius20 center marginL10"
                                     style="background: #4C95EF; color:white">
                                    静配
                                </div>
                            </div>
                            <div v-for="(cItem,cIndx) in item2">
                                <div class="font17 fontBold marginT5">{{cItem.orderInfo.arcimDesc}}</div>
                                <div v-if="cItem.orderInfo.doseQtyUnit" class="font14 gray marginT5">{{cItem.orderInfo.doseQtyUnit}}</div>
                            </div>
                            <div class="font14 gray marginT5">
                                {{item2[0].orderInfo.sttDateTime + "  " + item2[0].orderInfo.phcinDesc + "  " + item2[0].orderInfo.phcfrCode + "  " + getText(item2[0].orderInfo.ctcpDesc)}}
                            </div>
                            <div class="font14 gray marginT5">{{item2[0].orderInfo.seeOrderUserDateTime + " " + item2[0].orderInfo.seeOrderUserName}}</div>
                            <div class="line marginTB5"></div>
                        </div>
                    </div>
            </div>
        </div>
    </div>
    <mt-datetime-picker ref="picker" type="datetime"
                        year-format="{value}年"
                        month-format="{value}月"
                        date-format="{value}日"
                        hour-format="{value}时"
                        minute-format="{value}分"
                        v-model="pickerTime" @confirm="handleConfirm"/>
</div>
</body>
<script>
    var tag = ""
    var tUserId="18885";
    var tLocId="8";
    var tWardId="3";
    var tGroupId="23";
    var tHospitalId="2";
    var tPageNo="1";
    var tSheetCode="";

    function getString(s) {
        if (tag == "USERID") {
            tUserId = s;
            getSPString("LOCID") //第2个调用
        } else if (tag == "LOCID") {
            tLocId = s;
            getSPString("WARDID") //第3个调用
        } else if (tag == "WARDID") {
            tWardId = s;
        }
    }

    function getSPString(key) {
        if (window.android) {
            tag = key;
            window.android.callAndroid("com.blankj.utilcode.util.SPStaticUtils:getString(" + key + ")", "call");
        }
    }
    //添加鸿蒙 传递用户信息
    window.addEventListener('message', function (event) {
        if (event.data === 'init_web_messageport') {
            if (event.ports[0] != null) {
                h5Port = event.ports[0]; // 1. 保存从ets侧发送过来的端口
                h5Port.onmessage = function (event) {
                    var result = event.data;// 2. 接收ets侧发送过来的消息.
                    console.log("In html got message, result: ", (result));
                    if (typeof (result) == "string") {
                        //固定格式：hospitalId,groupId,wardId,userId,locId
                        var arr = result.split(",");
                        tHospitalId = arr[0];
                        tGroupId = arr[1];
                        tWardId = arr[2];
                        tUserId = arr[3];
                        tLocId = arr[4];
                        var txt = tHospitalId + "-" + tGroupId + "-" + tWardId + "-" + tUserId + "-" + tLocId
                        //document.getElementById("msg").innerHTML = "String:" + result + "=" + txt
                        initVue();
                    }
                }
            }
        }
    })
    //第1个调用
    getSPString("USERID")

    function initVue() {
        new Vue({
            el: '#app',
            data: {
                selected: 0,
                pickerTime: "2023-04-27 13:13",
                stDateTime: "2023-04-27 13:13",
                endDateTime: "2023-04-28 13:13",
                tag: "start",
                sheetList: [],
                orders: [],
            },
            watch: {
                selected(val) {
                    console.log(val)
                    tSheetCode = this.sheetList[val].code
                    this.initData()
                }
            },
            mounted() {
                //将要给原生调用的方法挂载到 window 上面
                window.Config = this.Config
                window.getScanMsg = this.getScanMsg
                window.GetOrders = this.GetOrders
                this.initData()
            },
            methods: {
                //获取扫码
                getScanMsg(scanInfo) {
                    this.$toast(scanInfo)
                },
                GetOrders(data) {
                    Http.hideLoading(this)
                    this.sheetList = data.sheetList
                    this.orders = data.orders
                },
                getText(txt) {
                    if (txt) return txt
                    return ""
                },
                initData() {
                    var startDate = this.stDateTime.split(" ")[0]
                    var startTime = this.stDateTime.split(" ")[1]
                    var endDate = this.endDateTime.split(" ")[0]
                    var endTime = this.endDateTime.split(" ")[1]
                    Http.showLoading(this)
                    //{"endDate":"2023-05-12","groupId":"23","bedStr":"","wardId":"3","userId":"18885","hospitalId":"2",
                    // "pageNo":"1","startTime":"08:48","endTime":"08:48","locId":"8","startDate":"2023-05-12" OrderSearchFragment.html
                    var params = {
                        groupId: tGroupId,
                        sheetCode: tSheetCode,
                        bedStr: "",
                        wardId: tWardId,
                        userId: tUserId,
                        hospitalId: tHospitalId,
                        pageNo: tPageNo,
                        limitNo: "20",
                        locId: tLocId,
                        startDate: startDate,
                        startTime: startTime,
                        endDate: endDate,
                        endTime: endTime
                    };
                    Http.postPlus("GetOrders", params, (data) => {
                        console.log(data)
                        this.GetOrders(data);
                    })
                },
                clickDateTime(tag) {
                    this.tag = tag
                    this.pickerTime = tag
                    this.$refs.picker.open();
                },
                handleConfirm(val) {
                    console.log(val)
                    if (val instanceof Object) {
                        var dt = this.getDt(val);
                        if (this.tag == this.stDateTime) this.stDateTime = dt
                        if (this.tag == this.endDateTime) this.endDateTime = dt
                        this.initData()
                    }
                },
                getDt(val) {
                    var month = val.getMonth() + 1;
                    if (month < 10) month = '0' + month;
                    var day = val.getDate();
                    if (day < 10) day = '0' + day;
                    var dt = val.getFullYear() + "-" + month + "-" + day + " " + val.getHours() + ":" + val.getMinutes()
                    return dt
                },
                getDisposeStatColor(sta) {
                    var col = sta.split("^")[1]
                    console.log(col)
                    return 'background: ' + col + '; color:white'
                },
            }
        })
    }

    var ua = navigator.userAgent
    if (ua.includes("OpenHarmony") || ua.includes("Linux")) {
        //鸿蒙不处理
    } else if (ua.includes("Mozilla") || ua.includes("AppleWebKit") || ua.includes("Safari") || ua.includes("Chrome") || ua.includes("Edg")) {
        initVue() //浏览器 直接打开
    }

</script>

</html>